/ leetcodesolve / Toph.co / CGPA, the Golden Egg!.py
swadhinbiswas update on Solver.countCGPA()Solver.countCGPA()Solver.countCGPA()Solver.countCGPA() · 1/15/2025
89a4b16
17 lines · 452 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Solve:
    def countCGPA():
        for i in range(int(input())):
            p=f=g=0
            for j in [1]*int(input()):
                m,c=map(float,input().split());p+=c
                if m<40:f+=1
                elif m>=80:g+=4*c
                else:g+=c*(m//5)/4
            print("Case %d: %s"%(i+1,('%.2f'%(g/p),'Sorry, you have failed in %d course%s!'%(f,('s','')[f<2]))[f>0]))




if __name__ == '__main__':
    Solve.countCGPA()